﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using KTVConsole2.Core;

namespace KTVConsole2.UI
{
    /// <summary>
    /// Interaction logic for UserControlSongPlayedDisplayByStar.xaml
    /// </summary>
    public partial class UserControlSongPlayedDisplayByStar : UserControl
    {
        public UserControlSongPlayedDisplayByStar()
        {
            InitializeComponent();
        }

        private void PlayAll_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            btn.IsEnabled = false;
            var star = btn.Tag as SongPlayed;
            var songList = MainWindow.Sm.GetSongsOfFavoriteStar(star);
            foreach (var a in songList)
            {
                MainWindow.Engine.AddSongToPlayList(a.Song);
            }            
        }

        private void DeleteAll_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            btn.IsEnabled = false;
            var star = btn.Tag as SongPlayed;
            var songList = MainWindow.Sm.GetSongsOfFavoriteStar(star);
            foreach (var a in songList)
            {
                MainWindow.Sm.DeleteSong(a);
            }
        }

        private void lvStarList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lvStarList.Items.IsCurrentAfterLast || lvStarList.Items.IsEmpty || lvStarList.Items.IsCurrentBeforeFirst)
                return;
            var selectSong = lvStarList.SelectedItem as SongPlayed;
            userControlSongPlayedDisplayBySong1.listView1.ItemsSource = MainWindow.Sm.GetSongsOfFavoriteStar(selectSong);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
    }
}
